<!DOCTYPE html>
<html>

<body>
    <p id="demo" onclick = "changec()">demo </p>

    <script>
            function changec(){
            x = document.getElementById('demo');
            x.style.color = "green";
            }
            //changec();
    </script>
   
</body>

</html>